const {
	ERROR
} = require('../../common/error');

module.exports = async function(params = {}) {
	const {
		userId
	} = params;

	console.log(params);

	if (userId) {
		const result = await uniCloud.database().collection("uni-id-users").where({
			_id: userId
		}).get();

		if (result.data.length > 0) {
			const user = result.data[0];
			return {
				errCode: 0,
				is_member: user.is_member,
			}
		}
		throw {
			errCode: ERROR.ACCOUNT_NOT_EXISTS
		}
	}
	throw new Error('Invalid user query');
}